package org.nullauthor.allthings.mods;

import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.Rarity;
import org.nullauthor.allthings.Allthings;
import org.nullauthor.allthings.items.DreamFragment;
import org.nullauthor.allthings.items.SecretShadowDust;

public class ModItems {
    public static final Item DREAM_FRAGMENT = registerItem("dream_fragment", new DreamFragment(new Item.Settings().rarity(Rarity.UNCOMMON)));
    public static final Item SECRET_SHADOW_DUST = registerItem("secret_shadow_dust", new SecretShadowDust(new Item.Settings().rarity(Rarity.UNCOMMON)));
    public static final Item MYSTERIOUS_BOOK = registerItem("mysterious_book", new SecretShadowDust(new Item.Settings().rarity(Rarity.UNCOMMON)));

    public static Item registerItem(String id, Item item) {
        return Registry.register(Registries.ITEM, new Identifier(Allthings.MOD_ID, id), item);
    }

    public static Item register(String id, Item item) {
        return register(new Identifier(Allthings.MOD_ID, id), item);
    }

    public static Item register(Identifier id, Item item) {
        return register(RegistryKey.of(Registries.ITEM.getKey(), id), item);
    }

    public static Item register(RegistryKey<Item> key, Item item) {
        if (item instanceof BlockItem) {
            ((BlockItem)item).appendBlocks(Item.BLOCK_ITEMS, item);
        }

        return Registry.register(Registries.ITEM, key, item);
    }

    public static void registerItems() {

    }
}
